#ifndef _SPRITE_H_
#define _SPRITE_H_

#include "Entity.h"
#include "TextureManager.h"
namespace Engine{
	enum CollisionType {
		COLLISION_NONE = 0,
		COLLISION_RECT = 1,
		COLLISION_DIST = 2
	};
	class Sprite : public Entity{

	private:
		bool visible;
		bool alive;
		int lifetimeLength;
		sf::Clock lifetimeTimer;
		int objecttype;
		sf::Vector2f position;
		sf::Vector2f velocity;
		bool imageLoaded;
		int state;
		int direction;
		sf::Clock frameClock;
		sf::Clock moveClock;
	protected:

		sf::Sprite *sprimage;
		sf::Texture *tximage;

		int width,height;
		int animcolumns;
		int framestart,frametimer;
		int movestart, movetimer;
		bool collidable;
		enum CollisionType collisionMethod;
		int curframe,totalframes,animdir;
		double faceAngle, moveAngle;
		int animstartx, animstarty;
		double rotation, scaling;
		sf::Color color;
	public:
		//screen position
		sf::Vector2f getPosition() { return position; }
		void setPosition(sf::Vector2f position) { this->position = position; }
		void setPosition(double x, double y) { position.x = x; position.y = y;}

		double getX() { return position.x; }
		double getY() { return position.y; }
		void setX(double x) { position.x = x; }
		void setY(double y) { position.y = y; }

		//movement velocity
		sf::Vector2f getVelocity() { return velocity; }
		void setVelocity(sf::Vector2f v) { this->velocity = v; }
		void setVelocity(double x, double y) { velocity.x = x; velocity.y = y; }

		//image size
		void setSize(int width, int height) { this->width = width; this->height =
		height; }
		int getWidth() { return this->width; }
		void setWidth(int value) { this->width = value; }
		int getHeight() { return this->height; }
		void setHeight(int value) { this->height = value; }
		bool getVisible() { return visible; }
		void setVisible(bool value) { visible = value; }
		bool getAlive() { return alive; }
		void setAlive(bool value) { alive = value; }
		int getState() { return state; }
		void setState(int value) { state = value; }
		int getDirection() { return direction; }
		void setDirection(int value) { direction = value; }
		int getColumns() { return animcolumns; }
		void setColumns(int value) { animcolumns = value; }
		int getFrameTimer() { return frametimer; }
		void setFrameTimer(int value) { frametimer = value; }
		int getCurrentFrame() { return curframe; }
		void setCurrentFrame(int value) { curframe = value; }
		int getTotalFrames() { return totalframes; }
		void setTotalFrames(int value) { totalframes = value; }
		int getAnimationDirection() { return animdir; }
		void setAnimationDirection(int value) { animdir = value; }
		double getRotation() { return rotation; }
		void setRotation(double value) { rotation = value; }
		double getScale() { return scaling; }
		void setScale(double value) { scaling = value; }
		void setColor(sf::Color col) { color = col; }
		int getMoveTimer() { return movetimer; }
		void setMoveTimer(int value) { movetimer = value; }
		bool isCollidable() { return collidable; }
		void setCollidable(bool value) { collidable = value; }
		CollisionType getCollisionMethod() { return collisionMethod; }
		void setCollisionMethod(CollisionType type) { collisionMethod = type; }

	public:
		Sprite();
		virtual ~Sprite();
		void setImage(std::string filename);
		void move();
		void animate();
		void draw(sf::RenderWindow &window);
		void cleanUp();

		void onCollide(Entity &entity){}
		void onUse(Entity &entity){}
	}; //class
}; //namespace

#endif